package com.hsmpay.mobile.service.trans.impl;

import com.hsmpay.common.pojo.qian4.Qian4SendLog;
import com.hsmpay.common.service.impl.BaseServiceSupport;
import com.hsmpay.mobile.dao.trans.Qian4SendLogDao;
import com.hsmpay.mobile.service.trans.Qian4SendLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 调用千4接口日志表 服务 接口 qian4SendLogService
 * 对应pojo Qian4SendLog
 *
 * @param <Entity>
 * @param <Query>
 * @author 颜铃璋
 *         创建时间：2013-8-30
 */
@Service("qian4SendLogService")
public class Qian4SendLogServiceImpl extends BaseServiceSupport<Qian4SendLog, Long> implements Qian4SendLogService<Qian4SendLog, Long> {
    @Resource(name = "qian4SendLogDao")
    private Qian4SendLogDao<Qian4SendLog, Long> qian4SendLogDao;

    /**
     * 修改 银联应答码 银行交易信息
     *
     * @param Id
     * @param responseCode
     * @param bankMessage
     * @return
     * @throws Exception
     */
    public int updateResCodeMassage(Long id, String responseCode, String bankMessage) throws Exception {
        Qian4SendLog send = new Qian4SendLog();
        send.setId(id);
        send.setResponseCode(responseCode);
        send.setBankMessage(bankMessage);
        return qian4SendLogDao.updateResCodeMassage(send);
    }

    /**
     * 修改 银联应答码 银行交易信息
     *
     * @param terminalId
     * @param merchantOrderId
     * @param responseCode
     * @param bankMessage
     * @return
     * @throws Exception
     */
    public int updateResCodeMassage(String terminalId, String merchantOrderId, String responseCode, String bankMessage) throws Exception {
        Qian4SendLog send = new Qian4SendLog();
        send.setTerminalId(terminalId);
        send.setMerchantOrderId(merchantOrderId);
        send.setResponseCode(responseCode);
        send.setBankMessage(bankMessage);
        return qian4SendLogDao.updateResCodeMassage(send);
    }

    /**
     * 根据商户流水号 查询日志信息
     *
     * @param merchantOrderId
     * @return
     * @throws Exception
     */
    public Qian4SendLog getQian4SendLogByMOrderId(String merchantOrderId) throws Exception {
        return qian4SendLogDao.getQian4SendLogByMOrderId(merchantOrderId);
    }

    /**
     * 接口返回结果时 修改日志信息
     *
     * @param send
     * @return
     * @throws Exception
     */
    public int updateByResult(Qian4SendLog send) throws Exception {
        return qian4SendLogDao.updateByResult(send);
    }
    /**
     * 查询 一分钟内同个用户，通张卡 成功的查询余额笔数
     * @param sendLog
     * @return
     * @throws Exception
     */
    public int getEntityCountss(Qian4SendLog sendLog) throws  Exception{
        return qian4SendLogDao.getEntityCounts(sendLog);
    }
    /**
     * 查询 一天内同个用户 成功的查询余额笔数
     * @param sendLog
     * @return
     * @throws Exception
     */
    public int getEntityCounts(Qian4SendLog sendLog) throws  Exception{
        return qian4SendLogDao.getEntityCountss(sendLog);
    }
}
